import os
import shutil
def countTFace():
    path="F:\data\ThreeBallFace"
    imglist=os.listdir(path)
    for imgfile in imglist:
        if "whiteFace_face" in imgfile:
            bashname=imgfile.split(".")[0]
            imgjson = imgfile.replace(".jpg", ".json")
            leftfile=imgfile.replace("whiteFace_face","whiteLeft_left")
            leftjson=leftfile.replace(".jpg", ".json")
            rightfile=imgfile.replace("whiteFace_face","whiteRight_right")
            rightjson=rightfile.replace(".jpg", ".json")
            if os.path.exists(os.path.join(path,imgjson)):
                if os.path.exists(os.path.join(path,leftfile)) and os.path.exists(os.path.join(path,leftjson)):
                    if os.path.exists(os.path.join(path,rightfile)) and os.path.exists(os.path.join(path,rightjson)):
                        bashfold=os.path.join(path,bashname)
                        os.mkdir(bashfold)
                        shutil.move(os.path.join(path,imgfile),os.path.join(bashfold,imgfile))
                        shutil.move(os.path.join(path, imgjson), os.path.join(bashfold, imgjson))
                        shutil.move(os.path.join(path, leftfile), os.path.join(bashfold, leftfile))
                        shutil.move(os.path.join(path, leftjson), os.path.join(bashfold, leftjson))
                        shutil.move(os.path.join(path, rightfile), os.path.join(bashfold, rightfile))
                        shutil.move(os.path.join(path, rightjson), os.path.join(bashfold, rightjson))
